<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/7/11 0011
  Time: 下午 4:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<html>
<head>
    <title>Title</title>
    <script src="../../js/jquery-3.3.1.min.js" charset="utf-8"></script>
    <script src="../../js/cookie/jquery.cookie.js" charset="utf-8"></script>
    <script src="../../layui-v2.2.5/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="../../layui-v2.2.5/layui/css/layui.css" media="all">
    <%--<style>--%>
        <%--.input1{--%>
            <%--width:10%;--%>
            <%--display: inline-block;--%>
        <%--}--%>
        <%--.layui-form-item{--%>
            <%--text-align: center;--%>
        <%--}--%>
        <%--.fl{--%>
            <%--display: inline-block;--%>
            <%--float: none;--%>
        <%--}--%>
        <%--.form1{--%>
            <%--padding-top: 150px;--%>
        <%--}--%>
    <%--</style>--%>
</head>
<body>
<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right;margin-right: 100px"  href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon" style="line-height:30px">ဂ</i></a>
<form class="layui-form form1" action="">
    <div class="layui-form-item">

        <div class="layui-input-block">
            <label class="layui-form-label fl">一级返利</label>
            <input type="text" name="one" value="${ruleInfo.oneRebate}"
                   required  lay-verify="moneyCheck"
                   autocomplete="off" placeholder="请输入金额" class="layui-input input1">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <label class="layui-form-label fl">二级返利</label>
            <input type="text" name="two" required  lay-verify="moneyCheck"
                 value="${ruleInfo.twoRebate}"  autocomplete="off" placeholder="请输入金额" class="layui-input input1">
        </div>
    </div>
<%--    <div class="layui-form-item">

        <div class="layui-input-block">
            <label class="layui-form-label fl">三级返利</label>
            <input type="text" name="three" lay-verify="title" autocomplete="off" placeholder="请输入比例" class="layui-input input1">%
        </div>
    </div>
    <div class="layui-form-item">

        <div class="layui-input-block">
            <label class="layui-form-label fl">四级返利</label>
            <input type="text" name="four" lay-verify="title" autocomplete="off" placeholder="请输入比例" class="layui-input input1">%
        </div>
    </div>
    <div class="layui-form-item">

        <div class="layui-input-block">
            <label class="layui-form-label fl">五级返利</label>
            <input type="text" name="five" lay-verify="title" autocomplete="off" placeholder="请输入比例" class="layui-input input1">%
        </div>
    </div>--%>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
        </div>
    </div>
</form>
<script>
    //Demo
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form;
        var laydate=layui.laydate;


        form.verify({
            moneyCheck: [
                /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/
                ,'请输入正确返利金额，单位元'
            ]
        });



        //监听提交
        form.on('submit(formDemo)', function(data){
            //layer.msg(JSON.stringify(data.field));
            console.log(JSON.stringify(data.field));
            $.ajax({
                url:'/marketing/saveConfigRule',
                type:'POST', //GET
                async:true,    //或false,是否异步
                data:{
                    one:data.field.one,
                    two:data.field.two,
                },
                timeout:5000,    //超时时间
                dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                beforeSend:function(xhr){
                    /*console.log(xhr)
                     console.log('发送前')*/
                },
                success:function(data){
                    console.log(data);
                    if (data.code=='000000'){
                        layer.msg(data.msg,{time:1000,icon: 6});
                    }else {
                        layer.msg(data.msg,{time:1000,icon: 5});
                    }
                    //console.log(data)
                },
                error:function(xhr,textStatus){
                    console.log('错误')
                    console.log(xhr)
                    console.log(textStatus)
                },
                complete:function(){
                    //console.log('结束')
                }
            });
            return false;
        });
    });
</script>

</body>
</html>
